package com.taxi.apipassenger.service;

import com.taxi.apipassenger.remote.ServiceOrderClient;
import com.taxi.apipassenger.request.OrderRequest;
import com.taxi.common.constant.IdentityConstants;
import com.taxi.common.dto.OrderInfo;
import com.taxi.common.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Ruomeng
 * @Date: 2022/10/13
 * @Description : online-taxi
 * @Version: 1.0
 */
@Service
public class OrderService {
    @Autowired
    ServiceOrderClient serviceOrderClient;

    /**
     * 创建订单/下单
     * @param orderRequest
     * @return
     */
    public ResponseResult add(OrderRequest orderRequest){
        return serviceOrderClient.add(orderRequest);
    }

    /**
     * 乘客下单---创建预约单
     * @param orderRequest
     * @return
     */
    public ResponseResult book(OrderRequest orderRequest){
        return serviceOrderClient.book(orderRequest);
    }

    /**
     * 取消订单
     * @param orderId
     * @return
     */
    public ResponseResult cancel(Long orderId){
        return serviceOrderClient.cancel(orderId, IdentityConstants.PASSENGER_IDENTITY);
    }

    /**
     * 订单详情
     * @param orderId
     * @return
     */
    public ResponseResult<OrderInfo> detail(Long orderId){
        return serviceOrderClient.detail(orderId);
    }

    /**
     * 当前订单
     * @param phone
     * @param identity
     * @return
     */
    public ResponseResult<OrderInfo> currentOrder(String phone, String identity){
        return serviceOrderClient.current(phone,identity);
    }
}
